package controller

import (
	"net/http"

	"example.com/m/demo14/models"
	"github.com/gin-gonic/gin"
)

type StudentController struct{}

func (con StudentController) CreateStudent(c *gin.Context) {
	stu := models.Student{Name: "小罗", Age: 21, Gender: "男"}
	models.DB.Create(&stu)
	c.JSON(http.StatusOK, gin.H{"status": "ok", "data": stu})
}

func (con StudentController) GetStudent(c *gin.Context) {
	var stu []models.Student
	// models.DB.Where("name=? AND gender=?", "小罗", "女").First(&stu)
	models.DB.Where("gender=?", "女").Find(&stu)
	c.JSON(http.StatusOK, gin.H{"status": "ok", "data": stu})
}
